package openbang.account.web.portal.widget;

import openbang.common.vo.SelectModel;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.CheckBox;

public class OpenCheckBox extends CheckBox{
	SelectModel model = null;
    public OpenCheckBox(SelectModel model){
    	super();
    	this.model = model;
    	this.setText(model.getName());
    	this.setTitle(model.getRemark());
    	this.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
			public void onValueChange(ValueChangeEvent<Boolean> event) {
				updateSelected(event.getValue());
			}});
    }
	public SelectModel getModel() {
		return model;
	}
	public void setModel(SelectModel model) {
		this.model = model;
	}
    public void updateSelected(boolean selected){
    	model.setSelected(selected);
    }
    @Override
    public void setValue(Boolean value) {
        super.setValue(value, false);
        updateSelected(value);
    }
}
